// xp_impersonatehandles.cpp
// -------------
// Extended stored procedure for testing named pipe impersonation.

#pragma once

// Required libs
//#pragma comment(lib,"Psapi.lib")
#pragma comment(lib,"Ws2_32.lib") 
//#pragma comment(lib,"Fwpuclnt.lib")
#pragma comment(lib,"C:\\Program Files\\Microsoft SQL Server\\90\\SDK\\Lib\\x86\\opends60.lib")
//                      ^^ this is the default path - adjust as needed if yours differs ^^

#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NON_CONFORMING_SWPRINTFS
#define WIN32_LEAN_AND_MEAN

#include <Windows.h>
#include <stdlib.h>
#ifndef UNICODE
#include <stdio.h>
#endif
//#include <Psapi.h>
#include <sqlext.h>
#include <tchar.h>
#include <srv.h>
//#include <TlHelp32.h>
//#include <WinSock2.h>
#include <Ws2tcpip.h>
//#include <winternl.h>

#ifndef XP_NOERROR
#define XP_NOERROR				0			// Used for Sql_Send* functions
#endif
#ifndef XP_ERROR
#define XP_ERROR				1			// Used for Sql_Send* functions
#endif

#define	TACOS_RULE				1

// Exports
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) ULONG __GetXpVersion();
	#ifdef __cplusplus
}
#endif

// Xsproc entry point
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) SRVRETCODE xp_impersonatehandles(SRV_PROC *srvproc);
	#ifdef __cplusplus
}
#endif

// Added for xp_loadlibrary() usage
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) bool xp_impersonatehandleslib(SRV_PROC *srvproc, TCHAR* tcParameters);
	#ifdef __cplusplus
}
#endif


SRVRETCODE	Sql_SendMsg(SRV_PROC *srvproc,TCHAR* tczMsg);
SRVRETCODE	Sql_SendErr(SRV_PROC *srvproc,TCHAR* tczMsg);

